package com.untour.seqid.config.leaf.segment.service.impl;

import com.untour.seqid.config.leaf.segment.repository.LeafAllocRepository;
import com.untour.seqid.config.leaf.segment.service.TagsService;
import com.untour.seqid.config.leaf.segment.domain.LeafAllocDO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Set;


@Service
public class DbTagsServiceImpl implements TagsService {
    @Resource
    private LeafAllocRepository leafAllocRepository;
    @Override
    public Set<String> queryAllBizTags() {
        return leafAllocRepository.queryAllBizTags();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public LeafAllocDO updateMaxIdAndGetLeafAlloc(String bizTag) {
        leafAllocRepository.updateMaxId(bizTag);
        return leafAllocRepository.getLeafAlloc(bizTag);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public LeafAllocDO updateMaxIdByCustomStepAndGetLeafAlloc(String bizTag,int step) {
        leafAllocRepository.updateMaxIdByCustomStep(bizTag,step);
        return leafAllocRepository.getLeafAlloc(bizTag);
    }
}
